<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>YUI History Test</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="./prototype.js"></script>
  <!-- Dependencies -->
  <script src="http://yui.yahooapis.com/2.4.1/build/yahoo/yahoo-min.js"></script>
  <script src="http://yui.yahooapis.com/2.4.1/build/event/event-min.js"></script>
  <!-- Browser History Manager source file -->
  <script src="http://yui.yahooapis.com/2.4.1/build/history/history-min.js"></script>
  <style type="text/css">
  <!--
  #yui-history-iframe { 
    position:absolute; 
    top:0; left:0; 
    width:1px; height:1px; 
    visibility:hidden; 
  } 
  -->
  </style>
</head>
<body>
<iframe id="yui-history-iframe" src="./blank1.html"></iframe> 
<input id="yui-history-field" type="hidden">
<script>
var said = "...";

function main(state) {
  switch(state) {
  case "myModuleDefaultState":
    $("msg").innerHTML = 
      "<input type='text' id='said'>" +
      "<button onclick='saidpage1()'>submit</button>";
    break;
  case "myModuleNewState1":
    $("msg").innerHTML = 
      "<a onclick='saidpage2()' href='javascript:void(0)'>click here</a>";
    break;
  case "myModuleNewState2":
    $("msg").innerHTML = "you said: " + said;
    break;
  }       
}

function saidpage1() {
  said = $F("said")
  YAHOO.util.History.navigate('myModule', 'myModuleNewState1')
}

function saidpage2() {
  YAHOO.util.History.navigate('myModule', 'myModuleNewState2')
}

(function () {
  var myModuleBookmarkedState = YAHOO.util.History.getBookmarkedState("myModule");
  // If there is no bookmarked state, assign the default state:
  var myModuleInitialState = myModuleBookmarkedState || "myModuleDefaultState";
  function myModuleStateChangeHandler (state) {
    // Update the UI of your module according to the "state" parameter
    main(state);
  }
  YAHOO.util.History.register("myModule", myModuleInitialState, myModuleStateChangeHandler);
  YAHOO.util.History.onReady(function () {
    var myModuleCurrentState = YAHOO.util.History.getCurrentState("myModule");
    // Update the UI of your module according to "myModuleCurrentState"
    main(myModuleCurrentState);
  });
  try {
    YAHOO.util.History.initialize("yui-history-field", "yui-history-iframe");
  } catch (e) {
    document.getElementById("msg").innerHTML = "Sorry, your browser(maybe Opera?) is not supported";
  };
})();
</script>
<div id="msg"></div>
</body>
</html>
